/*
** Text-based User Interface Library
** Copyright (C) 2008 Eric Day
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to:** Free Software Foundation, Inc. 
** 51 Franklin Street, Fifth Floor,
** Boston, MA  02110-1301, USA
*/ 

#ifndef _TUI_H
#define _TUI_H

#include "config.h"

#if HAVE_CURSES_H
#include <curses.h>
#endif
#if HAVE_POLL_H
#include <poll.h>
#endif
#if HAVE_SYS_POLL_H
#include <sys/poll.h>
#endif

struct _TUI;
typedef struct _TUI TUI;

/*
** tui functions
*/

/* initialize the tui components with a given application window height */
int tui_init(TUI **new_tui, struct pollfd *pfd, int app_win_height);

/* cleanup and destroy the tui components */
void tui_destroy(TUI *tui);

/* set the user prompt */
void tui_set_prompt(TUI *tui, char *prompt);

/* set status message */
int tui_set_status(TUI *tui, char *status, char center);

/* set application status message */
int tui_set_app_status(TUI *tui, char *status, char center);

/* set application handlers */
void tui_set_app_handlers(TUI *tui, void *app_data,
    int (*app_input)(TUI *tui, void *app_data, int key),
    int (*app_focus)(TUI *tui, void *app_data));

/* get application window */
WINDOW *tui_get_app_window(TUI *tui);

/* write a message to the scrolling window */
int tui_scroll_write(TUI *tui, char *msg);

/* printf a message to the scrolling window */
int tui_scroll_printf(TUI *tui, char *format, ...);

/* handle user input */
int tui_input(TUI *tui);

/* read a line from the input if it is available */
int tui_read(TUI *tui, char *buf, int len);

/* update the tui components */
int tui_update(TUI *tui);

#endif /* _TUI_H */
